package online.westonline.com.westonline.wedgit;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * 旋转图片
 * Created by xiatao on 2018/8/20.
 */

public class DownImgView extends ImageView {
    private boolean show;
    public DownImgView(Context context) {
        super(context);
    }

    public DownImgView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public DownImgView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public boolean isShow() {
        return show;
    }

    /**
     * 展示
     * @param show
     */
    public void show(boolean show)
    {
        this.show = show;
        roation();
    }

    /**
     * 旋转动画
     */
    private void roation() {
        if (show)
        {
            //展开
            this.animate().rotation(90).setDuration(300).start();
        }
        else
        {
            //收缩
            this.animate().rotation(0).setDuration(300).start();
        }
    }
}
